package com.hy.memoryassistant;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * Created by Mike on 03/03/2015.
 */
public class RemindersAdapter extends ArrayAdapter<Reminder> {

    private List<Reminder> reminders;

    public RemindersAdapter(Context context, int resource) {
        super(context, resource);
    }

    public RemindersAdapter(Context context, int resource, List<Reminder> objects) {
        super(context, resource, objects);

        reminders = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;

        if (v == null) {
            LayoutInflater inflater = LayoutInflater.from(getContext());

            v = inflater.inflate(R.layout.reminder_list_item, null);
        }

        Reminder r = reminders.get(position);

        TextView listItemTitle = (TextView) v.findViewById(R.id.list_item_title);
        listItemTitle.setText(r.title);

        TextView listItemPrompt = (TextView) v.findViewById(R.id.list_item_prompt);
        listItemPrompt.setText(r.prompt);

        return v;
    }


}
